<!DOCTYPE html>
<html>
  <script>
    function checkExtension(name, context_type) {
      var canvas = document.createElement("canvas");
      document.body.appendChild(canvas);

      var gl_context = canvas.getContext(context_type || "webgl");

      // If we don't have a GL context, give up now
      if (!gl_context) {
        webglTestHarness.reportResults(name, false, "Unable to initialize " + context_type + " context.");
      } else {
        var gl_extension = gl_context.getExtension(name);
        if (gl_extension) {
          webglTestHarness.reportResults(name, true, name + " was available");
        } else {
          webglTestHarness.reportResults(name, false, name + " was not available");
        }
      }

      webglTestHarness.notifyFinished(name);
    }

    function checkSupportedExtensions(expected_extensions, context_type) {
      var canvas = document.createElement("canvas");
      document.body.appendChild(canvas);

      var gl_context = canvas.getContext(context_type || "webgl");

      // If we don't have a GL context, give up now
      if (!gl_context) {
        webglTestHarness.reportResults(name, false, "Unable to initialize " + context_type + " context.");
      } else {
        var missing_list = [];
        var extension_list = gl_context.getSupportedExtensions();
        for (var i in extension_list) {
          var extension = extension_list[i];
          if (extension.indexOf("WEBKIT_") == 0)
            continue; // Skip WEBKIT_ prefixed extensions since they all have unprefixed variants at this point.
          var expected_index = expected_extensions.indexOf(extension);
          if (expected_index == -1) {
            missing_list.push(extension);
          }
        }

        if (missing_list.length == 0) {
          webglTestHarness.reportResults(name, true, "All " + context_type + " extensions are being tested.");
        } else {
          var error_string = "The following " + context_type + " extensions are not being tested and should be added to GetExtensionList() in content/test/gpu/gpu_tests/webgl_conformance_integration_test.py:";
          for (var i in missing_list) {
            error_string += "\n\t" + missing_list[i];
          }
          webglTestHarness.reportResults(name, false, error_string);
        }
      }

      webglTestHarness.notifyFinished(name);
    }
  </script>
  <body></body>
</html>
